package com.ytzl.demo.controller;

import com.ytzl.common.CodeResultEnums;
import com.ytzl.common.R;
import com.ytzl.common.ResponseDataUtils;
import com.ytzl.demo.service.HotCityHotelService;
import com.ytzl.vo.ItripHotCityHoteVo;
import com.ytzl.vo.SearchHotCityVO;
import org.apache.solr.client.solrj.SolrServerException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/api/hotellist")
public class HotelListController {

    @Resource
    private HotCityHotelService service;
    @PostMapping("/queryHotelListByHotCity")
    public R queryHotelListByHotCity(SearchHotCityVO searchHotCityVO) throws IOException, SolrServerException {
        if (searchHotCityVO == null||searchHotCityVO.getCityId()==null){
            return ResponseDataUtils.buildError(CodeResultEnums.CITY_ID_IS_NULL);
        }
        //获取数据
        List<ItripHotCityHoteVo> itripHotCityHoteVos=service.queryHotelCityList(searchHotCityVO);
        return ResponseDataUtils.buildSuccess(itripHotCityHoteVos);
    }
}
